﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;

namespace WindowsServerConsole
{
    class ConfigurationProvider : IConfigurationSectionHandler
    {
        #region IConfigurationSectionHandler Members

        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            XmlReader reader = new XmlNodeReader(section);

            XmlSerializer serializer = new XmlSerializer(typeof(ServerConfiguration));
            ServerConfiguration serverConfiguration = (ServerConfiguration)serializer.Deserialize(reader);
            return serverConfiguration;
        }

        #endregion
    }

    [Serializable]
    public class ServerConfiguration
    {
        string multicastAddress;
        [XmlElement]
        public string MulticastAddress
        {
            get { return multicastAddress; }
            set { multicastAddress = value; }
        }

        int multicastPort;
        [XmlElement]
        public int MulticastPort
        {
            get { return multicastPort; }
            set { multicastPort = value; }
        }

        int interval;
        [XmlElement]
        public int Interval
        {
            get { return interval; }
            set { interval = value; }
        }

        RMCs rmcs;
        [XmlElement]
        public RMCs RMCs
        {
            get { return rmcs; }
            set { rmcs = value; }
        }
    }

    [Serializable]
    public class RMCs
    {
        string[] rmc;
        [XmlElement(ElementName = "")]
        public string[] RMC
        {
            get { return rmc; }
            set { rmc = value; }
        }
    }
}
